//
//  XUIFoldList.h
//  etionUI
//
//  Created by wjxfhxy on 15/12/21.
//  Copyright (c) 2015年 GuangZhouXuanWu. All rights reserved.
//

#import "XUITableView.h"

typedef NS_ENUM(NSInteger, XUIFoldListRowAnimation)
{
    XUIFoldListRowAnimationFade  = UITableViewRowAnimationFade,
    XUIFoldListRowAnimationNone = UITableViewRowAnimationNone
};

@class XUIFoldList;

@interface XUIFoldListHeaderView : UITableViewHeaderFooterView

@property (nonatomic,readonly,retain) UIView *contentView;

@end

@interface XUIFoldListCell : XUITableViewCell

@end


@protocol XUIFoldListDelegate <NSObject>

- (CGFloat)foldList:(XUIFoldList*)foldList heightForRowAtIndexPath:(NSIndexPath*)indexPath;

- (CGFloat)foldList:(XUIFoldList *)foldList heightForHeaderInSection:(NSUInteger)section;

@optional

- (BOOL)foldList:(XUIFoldList *)foldList willClickedHeaderInSection:(NSUInteger)section preClickedHeaderInSection:(NSUInteger)preSection;

- (void)foldList:(XUIFoldList *)foldList didClickedHeaderInSection:(NSUInteger)section preClickedHeaderInSection:(NSUInteger)preSection;

- (BOOL)foldList:(XUIFoldList *)foldList deleteHeaderInSection:(NSUInteger)section;

- (BOOL)foldList:(XUIFoldList *)foldList willDisplayDeleteButtonInSection:(NSUInteger)section;

@end

@protocol XUIFoldListDataSource <NSObject>

- (NSInteger)numberOfSectionsInFoldList:(XUIFoldList *)foldList;

- (NSInteger)foldList:(XUIFoldList *)foldList numberOfRowsInSection:(NSUInteger)section;

- (XUIFoldListHeaderView*)foldList:(XUIFoldList*)foldList headerViewforHeaderInSection:(NSUInteger)section;

- (XUIFoldListCell*)foldList:(XUIFoldList *)foldList cellforRowAtIndexPath:(NSIndexPath *)indexPath;

@end

@interface XUIFoldList : UIView

@property(nonatomic,assign) id<XUIFoldListDelegate> delegate;
@property(nonatomic,assign) id<XUIFoldListDataSource> dataSource;

@property(nonatomic,assign) BOOL separatorExistFollowCell;

//只能同时展开一个Section
@property(nonatomic,assign) BOOL oneSectionUnfold;

- (void)registerClass:(Class)aClass forHeaderViewReuseIdentifier:(NSString *)identifier;

- (void)scrollCell:(XUIFoldListCell*)cell rectToVisible:(CGRect)rect animated:(BOOL)animated;

- (XUIFoldListHeaderView *)dequeueReusableHeaderViewWithIdentifier:(NSString *)identifier;

- (XUIFoldListHeaderView *)headerViewForSection:(NSUInteger)section;

- (XUIFoldListCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath;

- (NSIndexPath *)indexPathForCell:(XUIFoldListCell*)cell;

- (NSArray*)currentHeadViewSectionForFoldStatus:(BOOL)fold;

//- (NSUInteger)sectionForHeaderView:(XUIFoldListHeaderView*)headerView;

- (void)reloadData;

- (BOOL)foldStatusForSection:(NSUInteger)section;

- (void)reloadSections:(NSIndexSet *)sections withRowAnimation:(XUIFoldListRowAnimation)animation;

- (void)insertSections:(NSIndexSet *)sections withRowAnimation:(XUIFoldListRowAnimation)animation;

@end
